home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / etc / X11 / chooser.sh next >
Linux/UNIX/POSIX Shell Script  |  2006-04-12  |  2KB  |  65 lines

  1. #!/bin/sh
  2. # Copyright 1999-2004 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License, v2
  4. # Author:  Martin Schlemmer <azarah@gentoo.org>
  5. # $Header: /home/cvsroot/gentoo-x86/x11-base/xfree/files/4.3.99.8/chooser.sh,v 1.1 2003/07/11 22:54:09 spyderous Exp $
  6.  
  7. # If $XSESSION is "", source first /etc/conf.d/basic, and then /etc/rc.conf
  8. if [ -z "${XSESSION}" ]
  9. then
  10.     [ -f /etc/conf.d/basic ] && source /etc/conf.d/basic
  11.     [ -f /etc/rc.conf ] && source /etc/rc.conf
  12. fi
  13.  
  14. # Find a match for $XSESSION in /etc/X11/Sessions
  15. GENTOO_SESSION=""
  16. for x in /etc/X11/Sessions/*
  17. do
  18.     if [ "`echo ${x##*/} | awk '{ print toupper($1) }'`" \
  19.         = "`echo ${XSESSION} | awk '{ print toupper($1) }'`" ]
  20.     then
  21.         GENTOO_SESSION=${x}
  22.         break
  23.     fi
  24. done
  25.  
  26. GENTOO_EXEC=""
  27.  
  28. if [ -n "${XSESSION}" ]; then
  29.     if [ -f /etc/X11/Sessions/${XSESSION} ]; then
  30.         if [ -x /etc/X11/Sessions/${XSESSION} ]; then
  31.             GENTOO_EXEC="/etc/X11/Sessions/${XSESSION}"
  32.         else
  33.             GENTOO_EXEC="/bin/sh /etc/X11/Sessions/${XSESSION}"
  34.         fi
  35.     elif [ -n "${GENTOO_SESSION}" ]; then
  36.         if [ -x "${GENTOO_SESSION}" ]; then
  37.             GENTOO_EXEC="${GENTOO_SESSION}"
  38.         else
  39.             GENTOO_EXEC="/bin/sh ${GENTOO_SESSION}"
  40.         fi
  41.     else
  42.         x=""
  43.         y=""
  44.         
  45.         for x in "${XSESSION}" \
  46.             "`echo ${XSESSION} | awk '{ print toupper($1) }'`" \
  47.             "`echo ${XSESSION} | awk '{ print tolower($1) }'`"
  48.         do
  49.             # Fall through ...
  50.             if [ -x "`which ${x} 2>/dev/null`" ]; then
  51.                 GENTOO_EXEC="`which ${x} 2>/dev/null`"
  52.                 break
  53.             fi
  54.         done
  55.  
  56.         # If all else fail, run twm
  57.         GENTOO_EXEC="/usr/X11R6/bin/twm"
  58.     fi
  59. fi
  60.  
  61. echo "${GENTOO_EXEC}"
  62.  
  63.  
  64. # vim:ts=4
  65.